#include "userwidget.h"

UserWidget::UserWidget(QWidget *parent) : QWidget(parent)
{
     this->init_Widget();
    this->init_Control();
    this->init_Connect();
}

void UserWidget::init_Control()
{
    this->InBtn=new QPushButton();
    this->InBtn->setText(QString::fromUtf8("入库"));
    this->InBtn->setMaximumSize(200,100);
    this->OutBtn=new QPushButton();
    this->OutBtn->setText(QString::fromUtf8("出库"));
    this->OutBtn->setMaximumSize(200,100);
    this->DoBtn=new QPushButton();
    this->DoBtn->setText(QString::fromUtf8("库存盘点"));
    this->DoBtn->setMaximumSize(200,100);

    this->VLay=new QVBoxLayout();
    this->VLay->addWidget(this->InBtn);
    this->VLay->addWidget(this->OutBtn);
    this->VLay->addWidget(this->DoBtn);

    this->HLay=new QHBoxLayout();
    this->HLay->addStretch(1);
    this->HLay->addLayout(VLay);
    this->HLay->addStretch(1);

    this->setLayout(this->HLay);
}

void UserWidget::init_Widget()
{
    this->setWindowTitle(QString::fromUtf8("用户界面"));
    this->resize(800,600);
    this->inwidget=new InWidget();
    this->outwidget=new OutWidget();
    this->lookingWidget=new LookingTingsWidget();
}

void UserWidget::init_Connect()
{
       connect(this->InBtn,SIGNAL(clicked()),this,SLOT(on_InBtn_cliked()));
       connect(this->OutBtn,SIGNAL(clicked()),this,SLOT(on_OutBtn_cliked()));
       connect(this->DoBtn,SIGNAL(clicked()),this,SLOT(on_DoBtn_cliked()));
       connect(this->inwidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
      connect(this->outwidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
      connect(this->lookingWidget,SIGNAL(returnManager()),this,SLOT(showMyself()));
}

void UserWidget::on_InBtn_cliked()
{
    this->hide();
    this->inwidget->show();
}

void UserWidget::on_OutBtn_cliked()
{
   this->hide();
    this->outwidget->show();
}

void UserWidget::on_DoBtn_cliked()
{
    this->hide();
   this->lookingWidget->show();
}

void UserWidget::showMyself()
{
    this->inwidget->close();
    this->outwidget->close();
    this->lookingWidget->close();
    this->show();
}
